package com.tyj.movie.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 日期: 2021/7/2 21:43
 * 作者: 谭友杰
 * 类说明:
 */
@Configuration
public class ThreadPoolConfig {
    @Value("${thread.core-size}")
    private Integer coreSize;
    @Value("${thread.max-size}")
    private Integer maxSize;
    @Value("${thread.keep-alive-time}")
    private Integer keepAliveTime;

    @Bean
    public ThreadPoolExecutor threadPoolExecutor() {
        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(coreSize,maxSize,keepAliveTime, TimeUnit.SECONDS,new LinkedBlockingDeque<>());
        return threadPoolExecutor;
    }
}
